package org.xczy.order.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/order")
public class OrderController {

  private final String STOCK_URL = "http://spring-cloud-stock-nacos";

  @Resource
  private RestTemplate restTemplate;

  @GetMapping("/stock")
  public Map<String, String> add(){
    Map<String, String> map = new HashMap<>();
    String s = restTemplate.getForObject(STOCK_URL + "/stock/redact",String.class);
    map.put("mes", "成功 --> " + s);
    return map;
  }
}
